﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>student information management</title>
</head>
<style type="text/css">
.wrapper {width: 1000px;margin: 20px auto;}
h2 {text-align: center;}
.add {margin-bottom: 20px;}
.add a {text-decoration: none;color: #fff;background-color: green;padding: 6px;border-radius: 5px;}
td {text-align: center;}
</style>
<body>
    <div class="wrapper">
        <h2>student information management</h2>
        <div class="add">
            <a href="add.html">add</a>
        </div>
        <table width="960" border="1">
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>性别</th>
                <th>主修</th>
		<th>操作</th>
            </tr>

            <?php
                // 1.导入配置文件
                require "conn.php";
                // 2. 连接mysql
                $link = mysqli_connect(HOST,USER,PASS) or die("提示：数据库连接失败！");
		
    		// Create connection

                // 选择数据库
                mysqli_select_db($link,DBNAME);
                // 编码设置
                mysqli_set_charset($link,'utf8');

                
                $sql = "SELECT * FROM `41812209`";
                // 结果集
                $result = mysqli_query($link, $sql);
                // var_dump($result);die;

               
                //$Num=mysqsl_num_rows($result);  

               while ($row =  mysqli_fetch_array ($result)){
		 echo "<table>";
                    echo "<tr>";
                    echo "<td>".$row['ID']."</td>";
                    echo "<td>".$row["name"]."</td>";
                    echo "<td>".$row["sex"]."</td>";
                    echo "<td>".$row["major"]."</td>";
                    echo "<td>
                            <a href='javascript:del({$row['ID']})'>删除</a>
                            <a href='edit.php?ID={$row['ID']}'>修改</a>
                          </td>";
                    echo "</tr>";
		    echo "</table>";
                }
                // 5. 释放结果集
                //mysql_free_result($result);
                mysqli_close($link);
            ?>
        </table>
    </div>
    
    <script type="text/javascript">
        function del (ID) {
            if (confirm("Are you sure to delete?")){
                window.location = "action_del.php?ID="+ID;
            }
        }
    </script>
</body>
</html>